import { createSlice } from '@reduxjs/toolkit'
import dayjs from 'dayjs'

export const ciyt = createSlice({
    name: 'ciyt',
    initialState: {
        start: '北京',
        end: '广州',
        date:dayjs().format('YYYY-MM-DD')
    },
    reducers: {
        huan(start){
            let temp = start.start
            start.start = start.end
            start.end = temp
        },
        qie(state,{payload}){
            state[payload.type] = payload.city
        },
        dateq(state,{payload}){
            state.date = payload.date 
        }
    },
})

// Action creators are generated for each case reducer function
export const { huan,qie,dateq } = ciyt.actions

export default ciyt.reducer